package com.hqyj.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hqyj.exception.R;
import com.hqyj.pojo.TestStock;
import com.hqyj.dao.TestStockMapper;
import com.hqyj.service.TestStockService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author rock
 * @since 2023-04-20 03:01:23
 */
@Service
public class TestStockServiceImpl extends ServiceImpl<TestStockMapper, TestStock> implements TestStockService {
    @Resource
    TestStockMapper testStockMapper;


    @Override
    public Integer queryByShopId(Integer shopId) {
        QueryWrapper<TestStock> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("shopId",shopId);
        return testStockMapper.selectOne(queryWrapper).getNum();
    }

    @Override
    public boolean updateByShopId(TestStock t) {
        QueryWrapper<TestStock> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("shopId",t.getShopId());
        int num = testStockMapper.update(t,queryWrapper);
        if(num >0){
            return true;
        }
        return false;
    }
}
